package com.ruoyi.web.controller.course;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.course.domain.SysPaperTopic;
import com.ruoyi.course.service.ISysPaperTopicService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 试卷与题目关联Controller
 * 
 * @author yjf
 */
@RestController
@RequestMapping("/course/paperTopic")
public class SysPaperTopicController extends BaseController
{
    @Autowired
    private ISysPaperTopicService sysPaperTopicService;

    /**
     * 查询试卷与题目关联列表
     */
    @PreAuthorize("@ss.hasPermi('course:paperTopic:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysPaperTopic sysPaperTopic)
    {
        startPage();
        List<SysPaperTopic> list = sysPaperTopicService.selectSysPaperTopicList(sysPaperTopic);
        return getDataTable(list);
    }

    /**
     * 导出试卷与题目关联列表
     */
    @PreAuthorize("@ss.hasPermi('course:paperTopic:export')")
    @Log(title = "试卷与题目关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPaperTopic sysPaperTopic)
    {
        List<SysPaperTopic> list = sysPaperTopicService.selectSysPaperTopicList(sysPaperTopic);
        ExcelUtil<SysPaperTopic> util = new ExcelUtil<SysPaperTopic>(SysPaperTopic.class);
        util.exportExcel(response, list, "试卷与题目关联数据");
    }

    /**
     * 获取试卷与题目关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:paperTopic:query')")
    @GetMapping("/getInfo")
    public AjaxResult getInfo(SysPaperTopic sysPaperTopic)
    {
        return AjaxResult.success(sysPaperTopicService.getSysPaperTopicInfo(sysPaperTopic));
    }


    /**
     * 新增试卷与题目关联
     */
    @PreAuthorize("@ss.hasPermi('course:paperTopic:add')")
    @Log(title = "试卷与题目关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPaperTopic sysPaperTopic)
    {
        return toAjax(sysPaperTopicService.insertSysPaperTopic(sysPaperTopic));
    }

    /**
     * 删除试卷与题目关联
     */
    @PreAuthorize("@ss.hasPermi('course:paperTopic:remove')")
    @Log(title = "试卷与题目关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult remove(@RequestBody SysPaperTopic sysPaperTopic)
    {
        return toAjax(sysPaperTopicService.deleteSysPaperTopic(sysPaperTopic));
    }
}
